#pragma once

#include <vector>

#include "PlayerThread.h"

class SAPIModulator;
class TextProvider;
class SampleMarker;
class PlayerThread;

/*
VocoderController implements PlayerThreadListener and therefore receives notification when the current stream has ended.
It uses this notification to ask the SAPIModulator to produce more material.
Furthermore, the VocoderController gets called 
*/
class VocoderController : public PlayerThreadListener
{
public:
	VocoderController(void);
	~VocoderController(void);

	void Initialize(SAPIModulator* sapiModulator, TextProvider* textProvider, PlayerThread* playerThread);

	//Implementation of PlayerThreadListener
	void OnStreamEnded();

	//Are we playing now?
	bool IsPlaying();

	//Toggle play and stop playing (responding to ui)
	void PlayOrStop();

	//Stop playing
	void Stop();

	//Ask text provider for text and tell the SAPIMOdulator to produce the stream for that text
	void AddCurrentText();

	SAPIModulator* GetSAPIModulator();

private:
	bool isPlaying;
	SAPIModulator* sapiModulator;
	TextProvider* textProvider;
	PlayerThread* playerThread;
	std::vector<short> modulatorSample;


};
